package com.ryan.spring.annotation.model;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.Nullable;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created by kaimin on 28/1/2019.
 * time : 09:24
 */
public class Car implements InitializingBean,DisposableBean,BeanNameAware,BeanFactoryAware,ApplicationContextAware {

    public void init(){
        System.out.println("car init....");
    }

    public void destory(){
        System.out.println("car destory.....");
    }
    public void destroy() throws Exception {
        System.out.println("car DisposableBean的销毁逻辑");
    }

    public void afterPropertiesSet() throws Exception {
        System.out.println("car InitializingBean的set之后，完成初始化逻辑 ");
    }
    @PostConstruct
    public void PostConstruct(){
        System.out.println("car bean的PostConstruct ");
    }

    @PreDestroy
    public void PreDestroy(){
        System.out.println("car bean的PreDestroy ");
    }

    public void setBeanName(String s) {
        //获取这个bean在容器中的name
        System.out.println("BeanNameAware car 在容器中的名称是:"+s);
    }

    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        //回调到这个BeanFactory
        System.out.println("BeanFactoryAware car :");
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //拿到Spring的容器
        System.out.println("ApplicationContext car :"+applicationContext.getId());
    }


}
